package com.simen.hellobytes.android;

import android.view.View;
import android.view.ViewGroup;

/**
 * author: SimenHi
 * create time: 2020-05-09 10:24
 * description:
 */
public class ViewUtil {

    /**
     * 设置指定View临近的View的显示属性
     *
     * @param view        指定View
     * @param topOrbottom 临近View和指定View序列号的差值
     * @param visible     显示属性
     */
    public static void setRelativeViewVisible(View view, int topOrbottom, int visible) {
        ViewGroup parent = (ViewGroup) view.getParent();
        int index = parent.indexOfChild(view);

        View relativeView = parent.getChildAt(index + topOrbottom);
        if (relativeView != null) {
            relativeView.setVisibility(visible);
        }
    }

}
